import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Layouts from './../layouts/index.vue'
const routes: Array<RouteRecordRaw> = [
  {
    // 地址和component是必传的
    path: "/login",
    name: "login",
    component: () => import("../login/index.vue"),
  },
  {
    path: "/home",
    name: "home",
    component: () => import("../views/watchRoom/index.vue")
  },
  {
    // 地址和component是必传的
    path: "/index",
    name: "index",
    component: () => import("../views/home/index.vue"),
    children: [
      {
        // 默认子路由，通过 redirect 到 roomlist  
        path: '',

        redirect: 'videolist'
      },
      {
        path: "/roomlist",
        name: "roomlist",
        component: () => import("../views/home/roomlist.vue"),

      },
      {
        path: "/videolist",
        name: "videolist",
        component: () => import("../views/home/videolist.vue"),
      },
      {
        path: "/mycollect",
        name: "mycollect",
        component: () => import("../views/home/mycollect.vue"),
      },
      {
        path: "/mycenter",
        name: "mycenter",
        component: () => import("../views/home/mycenter.vue"),
      }
    ]
  }, {
    path: '/admin',
    name: '后台',
    component: Layouts,
    redirect: 'adminHome',
    children: [
      {
        path: '/adminHome',
        name: 'adminHome',
        component: () => import('../views/layoutAdmin/adminHome.vue')
      },
      {
        path: '/user',
        name: 'user',
        component: () => import('../views/layoutAdmin/user.vue')
      },
      {
        path: '/room',
        name: 'room',
        component: () => import('../views/layoutAdmin/room.vue')
      }
      ,
      {
        path: '/video',
        name: 'video',
        component: () => import('../views/layoutAdmin/video.vue')
      }
      ,
      {
        path: '/test',
        name: 'test',
        component: () => import('../views/layoutAdmin/Notices/test.vue')
      }
    ]
  },

];
const router = createRouter({
  history: createWebHistory(),
  routes: routes,
});
export default router;
